from django.db import models


# Create your models here.
class LinkModel(models.Model):
    """链接模型的抽象基类"""
    name = models.CharField("名称", max_length=100)
    url = models.CharField("链接", max_length=2048)
    priority = models.SmallIntegerField("优先级", default=0)
    enable = models.BooleanField("启用", default=True)

    class Meta:
        abstract = True

    def __unicode__(self):
        return self.name

    __str__ = __unicode__


class OptionModel(models.Model):
    name = models.CharField("名字", max_length=100)
    code = models.CharField("代码", max_length=100, unique=True)
    value = models.CharField("值", max_length=300)
    enable = models.BooleanField("启用", default=True)

    class Meta:
        verbose_name = "论坛全局配置"
        verbose_name_plural = "论坛配置"

    def __unicode__(self):
        return self.code

    __str__ = __unicode__


class PageModel(LinkModel):
    icon_code = models.CharField("图标代码", max_length=20, blank=True,
                                 help_text="http://www.layui.com/doc/element/icon.html")

    class Meta:
        verbose_name = "页面"
        verbose_name_plural = "页面设置"


class FooterLinkModel(LinkModel):
    class Meta:
        verbose_name = "底部链接"
        verbose_name_plural = verbose_name


class PassageWayModel(LinkModel):
    class Meta:
        verbose_name = "温馨通道"
        verbose_name_plural = verbose_name


class AdsModel(LinkModel):
    color = models.CharField("颜色", max_length=20, default='#5FB878', blank=True)

    class Meta:
        verbose_name = "广告"
        verbose_name_plural = "广告"


class FriendLinkModel(LinkModel):
    class Meta:
        verbose_name = "友情链接"
        verbose_name_plural = verbose_name
